import React from 'react';

const Product = ({match, data}) => {
  const product = data.find(p => p.id == match.params.productId);
  let productView;

  if (product)
    productView = <div>
      <h3>{product.name}</h3>
      <p>{product.description}</p>
      <hr/>
      <h4>{product.status}</h4>
    </div>
  else
    productView = <h2>Sorry. Product does not exist.</h2>
  
  return (
    <div>
      <div>{productView}</div>
    </div>
  );
}

export default Product;
